home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1999 #1 / Amiga Plus 1999 #1.iso / System-Boost / Workbench / LFSystemBinder / compagnons / Registry / For_Shell_Writters < prev    next >
Encoding:
Text File  |  1998-06-21  |  5.2 KB  |  133 lines

  1.  
  2.                         Notes for Shell writters...
  3.  
  4.             *****************************************************
  5.      If you write a tools that use or change Worbench PathList, please use
  6.     this very simple mechanism because no other locking is possible. This is
  7.     the only security aviable.
  8.                                 See below.
  9.             *****************************************************
  10.  
  11.      I write this library because I think some notifications' mechanisms are
  12.     missing in AmigaDos. For exemple: You can't be notified when an other
  13.     task change assign. More, some resources, like Workench path can't be
  14.     locked.
  15.  
  16.      If you program your shell in a Registery.library compatible ways,
  17.     others tasks, like system's monitors, may be notified when you change
  18.     something... You can declare others resources as you need (eg: for
  19.     custom IO/ports, IRControler, your coffee machine ...) and this library
  20.     provide a simple but powerfull locking mechanisme.
  21.  
  22.      Following resources are defined to monitor some standard systeme datas:
  23.  
  24.     Assign :
  25.     ~~~~~~~~
  26.      All is automaticly done by AssignPatch (included in this distribution).
  27.     As Dos's functions AssignAdd(), AssignLate(), AssignLock(), AssignPath()
  28.     and RemAssignList() are patched, all changes made are notified.
  29.  
  30.      In the system's monitor side, the resource is named "ASSIGN".
  31.     Note: Don't try to lock this resource because locked "ASSIGN" resource
  32.     means AssignPatch is running... The right way is to use the standard dos'
  33.     LockDosList() function. On the other hand, you may temporaly disable
  34.     notifications -RL_DisableNotifying()- if you make many changes at a
  35.     time.
  36.  
  37.     See TestNotify.c for an example source code for looking for notification.
  38.     If you change RL_RegisterClass("TST_RES_NOTIF") to "ASSIGN", TestNotify
  39.     is notified for all assign opération.
  40.  
  41.  
  42.     EnvVariables :
  43.     ~~~~~~~~~~~~~~
  44.      Like Assign, all is done by AssignPatch ( SetVar() and DeleteVar() are
  45.     patched and a dos notification is used to monitor direct file change in
  46.     ENV: - i.e: Use file functions for changing a variable).
  47.  
  48.      The resource name is "ENVVAR". Like for Assign, locking this resouce
  49.     doesn't do nothing.
  50.  
  51.  
  52.     Residents:
  53.     ~~~~~~~~~~
  54.      AssignPatch patch dos' AddSegment() and RemSegment() so adding or removing
  55.     a resident cause automaticaly notifications.
  56.  
  57.      The resouce name is "RESIDENT" and only a Forbid()/Permit() pair allow a
  58.     protection when you read this list, as all semaphore in dos structure are
  59.     private... Locking this resouce does nothing!
  60.  
  61.  
  62.     Path:
  63.     ~~~~~
  64.      Normaly, only CLI processes may access to there own Path list, so no
  65.     semaphore exist. But, the Workbench's one is concidered as "the global
  66.     path", because all others CLI may start from it. For tools that may
  67.     modifying this resource, registery.library permit a "better than nothing"
  68.     arbitration.
  69.  
  70.      The resource name is "WB_PATH".
  71.     Notes:
  72.         * ListRegistry does't display this resource if nobody use it - this
  73.     resource is totaly free in this case -.
  74.         * I know very few program that are working on WB PathList (CSH and
  75.     my very own LFSystemBinder).
  76.  
  77.      This example show how to use registry.library with a custom PATH command.
  78.     It's come from csh 5.40 source code, only "path -r[g]" section: remove an
  79.     existing path...
  80.  
  81.  
  82.             . . .
  83.  
  84.         if ( options&1 ) {  // Option -r : Remove
  85.                 long noram = 0;
  86.  --- « NEW »
  87. ||              APTR wbpathres;
  88. ||
  89. ||                if ( options&2 && RegistryBase ) {
  90. ||                    // Option -g : For all running CLI and if registry.library
  91. ||                    // could be openned.
  92. ||                    wbpathres = RL_RegisterResource("WB_PATH"); //register the resource
  93. ||                    if(!RL_LockResource(wbpathres,FALSE)){  // Try an exclusif lock
  94. ||                        RL_UnRegisterResource(wbpathres);
  95. ||                        ierror("Workbench PathList", ERROR_OBJECT_IN_USE);
  96. ||                            // Internal CSH func for printing an error message
  97. ||                        return 20;
  98. ||                    }
  99. ||                }
  100.  -----
  101.  
  102.                 Forbid();   // No other task may modif path-list
  103.                 mincli = 1;
  104.  
  105.                     . . .  ««« CSH stuff for erasing path »»»  . . .
  106.  
  107.                 Permit();
  108.  
  109.  ---- « NEW »
  110. ||                if ( options&2 && RegistryBase ) { // Some cleanup
  111. ||                    RL_UnLockResource(wbpathres);
  112. ||                    RL_Notify(wbpathres); // Hey, something have changed!
  113. ||                    RL_UnRegisterResource(wbpathres);
  114. ||                }
  115.  -----
  116.  
  117.                 if (noram>0) {
  118.  
  119.                         . . .
  120.  
  121.      Somes notes:
  122.         - options&2 means we want to change ALL paths (including WBPath) else
  123.     only our own path is changed - so no arbitration is needed as we are not
  124.     the Workbench !-.
  125.         - If "WB_PATH" resource can't be locked means another process use
  126.         this resource -> We *must* fail or we trash this process datas!
  127.         - We *must* notify ourself -RL_Notify()- for resource's modifications.
  128.  
  129.  
  130.  
  131.     CSH is (c) 1986 Matt. Dillon,
  132.         versions 5.20+ OS 2.0 versions by A. Kirchwitz, M. Berndt
  133.